limsEquiptRepair.implementPage = {

    getGridParam: function () {
        var _this = this;
        return {
            type: 'grid',
            id: 'equiptRepairGrid-implement',
            url: limsEquiptRepair.baseUrl + '/queries/tasks',
            service: 'limsEquiptRepairServiceImpl',
            dbTable: 'T_LIMS_EQUIPT_REPAIR',
            columns: limsEquiptRepair.getImplementListColumns(),
            requestData: {
                bpmn_statusCode: _this.param.bpmn_statusCode
            },
            onCellClick: function (field, row) {
                field === 'ext$.equiptcode' && _this.loadDetailPage(row.id);
            },
            toolbar: [{
                type: 'button',
                text: 'GIKAM.WORKFLOW.BUTTON.PASS',
                icon: 'pass',
                onClick: function () {
                    var comp = Gikam.getComp('equiptRepairGrid-implement');
                    if (!(comp.getSelections().length > 0) || !comp.validate(comp.getSelections())) {
                        return;
                    }
                    _this.pass();
                }
            }, {
                type: 'button',
                text: 'GIKAM.WORKFLOW.BUTTON.REJECT',
                icon: 'reject',
                onClick: function () {
                    _this.reject();
                }
            }]
        }
    },

    pass: function () {
        var grid = Gikam.getComp('equiptRepairGrid-implement');
        Gikam.create('workflow').pass({
            data: grid.getSelections(),
            pageObject: limsEquiptRepair
        }).done(function () {
            grid.refresh();
        });
    },

    reject: function () {
        var grid = Gikam.getComp('equiptRepairGrid-implement');
        Gikam.create('workflow').reject({
            data: grid.getSelections(),
            pageObject: limsEquiptRepair
        }).done(function () {
            grid.refresh();
        });
    },

    loadDetailPage: function (id) {
        workspace.window.load(limsEquiptRepair.baseUrl + '/page/detail' + Gikam.param({
            id: id,
            page: 'implement',
        }));
    },

    create: function () {
        var _this = this;
        Gikam.create('layout', {
            id: 'lims-equipt-repair-implement-list-layout',
            renderTo: workspace.window.$dom,
            center: {
                items: [this.getGridParam()]
            }
        });
    },

    init: function (param) {
        this.param = param;
        this.create();
    }
};
